package ygw.study.designPatterns.flyweight;

/**
 * <p>
 * 工厂类
 * </p>
 * <p>
 * Copyright:2021.All rights reserved.
 * </p>
 * <p>
 * Company:Zsoft
 * </p>
 * <p>
 * CreateDate:2021-05-19 20:09
 * </p>
 *
 * @author YuGongWen
 * @history Mender:YuGongWen；Date:2021-05-19 20:09；
 */

import java.util.HashMap;

public class ShapeFactory {
    
    private static final HashMap<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) circleMap.get(color);

        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("Creating circle of color : " + color);
        }
        return circle;
    }
}